<?php   
class ControllerModuleStore extends Controller {
	public function index() {
		$status = true;
		
		if ($this->setting->get('store_admin')) {
			$this->load->library('user');
		
			$this->user = new User($this->registry);
			
			$status = $this->auth->is_logged();
		}
		
		if ($status) {
			$this->language->load('module/store');
			
			$this->data['heading_title'] = $this->language->get('heading_title');
			
			$this->data['text_store'] = $this->language->get('text_store');
			
			$this->data['store_id'] = $this->setting->get('setting_store_id');
			
			$this->data['stores'] = array();
			
			$this->data['stores'][] = array(
				'store_id' => 0,
				'name'     => $this->language->get('text_default'),
				'url'      => $this->setting->get('http_server') . 'index.php?route=common/home&session_id=' . $this->session->get_id()
			);
			
			$this->app->model('setting/store', true, true);
			
			$results = $this->model_setting_store->getStores();
			
			foreach ($results as $result) {
				$this->data['stores'][] = array(
					'store_id' => $result['store_id'],
					'name'     => $result['name'],
					'url'      => $result['url'] . 'index.php?route=common/home&session_id=' . $this->session->get_id()
				);
			}
	
            $this->template = 'module/store.tpl';
			
			return $this->render();
		}
	}
}
?>
